package com.distributer.policy.thread;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ConcurrentHashMap;

import com.distributer.policy.request.Request;

public class RequestQueue {

	private final List<ArrayBlockingQueue<Request>> requestQueues;
	
	private final Map<String, Boolean> flagMaps;
	
	private RequestQueue(){
		this.requestQueues = new ArrayList<ArrayBlockingQueue<Request>>();
		this.flagMaps = new ConcurrentHashMap<String, Boolean>();
	}
	
	public void addQueue(ArrayBlockingQueue<Request> queue){
		this.requestQueues.add(queue);
	}
	
	public ArrayBlockingQueue<Request> getQueueByIndex(Integer index){
		return this.requestQueues.get(index);
	}
	
	public Map<String, Boolean> getFlagMap(){
		return this.flagMaps;
	}

	public int queueSize(){
		return this.requestQueues.size();
	}
	
	private static class RequestQueueInstance{
		
		private static RequestQueue requestQueue;
		
		static{
			requestQueue = new RequestQueue();
		}
		
		private RequestQueueInstance(){}
		
		private static RequestQueue instance(){
			return requestQueue;
		}
		
	}
	
	public static RequestQueue instance(){
		return RequestQueueInstance.instance();
	}
}
